package com.xucy.springboot.designmodel.structural.flyweight;

import java.util.HashMap;

/**
 * @Author xucy
 * @Date 2019-07-18 19:38
 * @Description
 **/

public class ManagerFactory {

    public static HashMap<String,Employee> managerMap=new HashMap<String,Employee>();

    /**
     * 创建部门经理。当map中有直接返回，没有创建就创建一个并放入到map中 以便之后使用
     *
     * @Author xucy
     * @Date 09:12 2019-07-19
     * @param
     * @return
     */
    public static Employee createEmployee(String dep){
        Employee employee=managerMap.get(dep);

        if(employee!=null){
            return employee;
        }else{
            System.out.println(dep+"过来创建了");
            employee=new Manager(dep);
            managerMap.put(dep,employee);

            return employee;
        }

    }

}
